package com.qa.mapper;

import com.qa.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author 徐
 */
@Mapper
public interface UserMapper {

    /**
     * 根据邮箱查询可用用户（status=1）
     *
     * @param mail 邮箱
     * @return 用户User
     */
    @Select("select * from user where mail = #{mail} and status = 1")
    User getUserByMail(String mail);

    /**
     * 添加用户
     *
     * @param user 用户
     * @return 影响行数
     */
    @Insert("insert into user (nickname, mail, password, avatar, status) values " +
            "(#{nickname}, #{mail}, #{password}, #{avatar}, #{status})")
    Integer addUser(User user);

    /**
     * 修改用户信息
     *
     * @param user 用户
     * @return 影响行数
     */
    Integer updateUser(User user);
}
